import os
import wmi

def list_files_by_volume_label(volume_label):
    """
    通过卷标获取文件列表

    Args:
        volume_label (str): 卷标名称，例如 "BK_01"

    Returns:
        list: 文件列表，如果未找到则返回空列表
    """
    try:
        # 连接到 WMI
        c = wmi.WMI()
        # 遍历所有逻辑磁盘
        for disk in c.Win32_LogicalDisk():
            if disk.VolumeName == volume_label:
                drive_letter = disk.DeviceID  # 例如 "G:"
                return os.listdir(drive_letter)
        print(f"未找到卷标为 '{volume_label}' 的驱动器")
        return []
    except Exception as e:
        print(f"查询过程中出现错误: {e}")
        return []

volume_label = "BK_01"  # 请替换为你的实际卷标
file_list = list_files_by_volume_label(volume_label)
print(f"卷标 '{volume_label}' 下的文件列表: {file_list}")